<template>

    <div> <el-dialog v-model="dialogVisible3" title="分享" width="500" :before-close="handleClose3">
            <el-form ref="ruleFormRef" :model="ruleForm" label-width="auto">
                <el-form-item prop="email" label="文件">
                    {{ ruleForm.fileName }}
                </el-form-item>
                <el-form-item prop="validType" label="有效期">

                    <el-radio-group v-model="ruleForm.validType">

                        <el-radio :value="0">1天</el-radio>
                        <el-radio :value="1">7天</el-radio>
                        <el-radio :value="2">30天</el-radio>
                        <el-radio :value="4">永久有效</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item prop="codeType" label="提取码">

                    <el-radio-group v-model="ruleForm.codeType">
                        <el-radio :value="0">自定义</el-radio>
                        <el-radio :value="1">系统生成</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item prop="code" v-if="ruleForm.codeType == 0">
                    <el-input v-model="ruleForm.code"></el-input>
                </el-form-item>
                <el-form-item>
                    <div style="text-align: center;width:100%">

                        <el-button type="info" @click="resetshare()">取消</el-button>
                        <el-button type="success" @click="submitshare()">确定</el-button>
                    </div>
                </el-form-item>
            </el-form>
        </el-dialog></div>
</template>
<script setup>
import service from '@/utils/Request'
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
const dialogVisible3 = ref(false)
const ruleForm = ref({})
const resetshare = () => {
    dialogVisible3.value = false
}
const submitshare = async () => {
    const res = await service.post("/share/shareFile", ruleForm.value);
    console.log(res);
    if (res.code == 1) {
        ElMessage({
            type: "success",
            message: "成功"
        })
        dialogVisible3.value = false
    } else {
        ElMessage({
            type: "warning",
            message: "失败"
        })
    }

}
const handleClose3 = () => {
    dialogVisible3.value = false
}
const open = (row) => {
    console.log(row)
    ruleForm.value.fileId = row.fileId
    dialogVisible3.value = true
    ruleForm.value.fileName = row.fileName

}
defineExpose({
    open
})
</script>